<template>
  <div>
    <el-row>
      <el-col :span="24">
        <h3>旧密码：</h3>
      </el-col>
      <el-col :span="24">
        <el-input v-model="change.oldPassWord" placeholder="请输入内容" style="width: 300px"></el-input>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <h3>新密码：</h3>
      </el-col>
      <el-col :span="24">
        <el-input v-model="change.newPassWord" placeholder="请输入内容" style="width: 300px"></el-input>
      </el-col>
    </el-row>
    <el-button style="margin-top: 50px;" type="warning" @click="remove">重置</el-button>
    <el-button style="margin-top: 50px;" type="success" @click="changePsd">修改</el-button>
  </div>
</template>

<script>
import request from '@/utils/request'
import { Message } from 'element-ui'
export default {
  data () {
    return {
      change: {
        oldPassWord: '',
        newPassWord: ''
      }
    }
  },
  methods: {
    remove () {
      this.change = {
        oldPassWord: '',
        newPassWord: ''
      }
    },
    changePsd () {
      request({
        url: '/my/updatePassWord',
        method: 'post',
        data: this.change
      }).then(res => {
        if (res.code === '00000000') {
          Message({
            message: res.message,
            type: 'success',
            duration: 3 * 1000
          })
          this.remove()
        } else {
          Message({
            message: res.message,
            type: 'error',
            duration: 3 * 1000
          })
        }
      })
    }
  }
}
</script>

<style>
</style>
